
//合成上传参数信息，并上传设备运行参数
function setParmsByDay(set) {
    var parms = document.getElementById("parms").getElementsByTagName("li");
    var checkParmResult = document.getElementsByName("checkParmResult");
    var updateParmResult = document.getElementById("updateParmResult");
    var updateParmDate = $("#updateParmDate").val();
    var pass = true;
    var parm = new Array();
    //判断参数是否完善
    for (var i=0;i<parms.length;i++){
        var number =  parms[i].getElementsByTagName("input");
        checkParmResult[i].innerHTML="";
        if (number[0].value!="" && number[1].value!=""){
            parm[i] = parseFloat(number[1].value + "." + number[1].value);
        }
        else {
            parm[i] = null;
            pass = false;
            showcheckParmResult(checkParmResult[i],"*参数不完善","15px");
        }
    }
    //判断参数是否完善
    if (pass == false){
        return
    }
    // 判断日期是否完善
    updateParmResult.innerHTML="";
    if (updateParmDate == ""){
        showcheckParmResult(updateParmResult,"*上传日期为空","15px");
        return;
    }
    console.log(updateParmDate);
    $.ajax({
        url:"updateParmsByDate",
        type:"post",
        dataType:"json",
        data:{
            "id":1,
            "updateTime":updateParmDate,
            "sulfurDioxide":parm[0],
            "nitrogenOxide":parm[1],
            "particulate":parm[2],
            "temperature":parm[3],
            "humidity":parm[4],
            "flow":parm[5],
            "oxygenContent":parm[6],
            "data":set
        },
        success:function (data) {
            console.log(data.result);
            if (data.result == false){
                showModal("有一些问题需要确认","数据库中已存在当天记录，是否提交更新？",false);
                $("#sdf").click();
            }
            else {
                showModal("上传成功",updateParmDate+"设备运行记录上传成功！",true);
                if ($("#myModal").css("display") == "none"){
                    $("#sdf").click();
                }
            }
        },
        error:function () {
            alert("出错了！")
        }
    })
}

//参数空或格式不正确提示
function showcheckParmResult(element,data,margin) {
    var sd =document.createElement("div");
    sd.innerText = data;
    sd.style.marginTop = margin;
    sd.style.textAlign = "center";
    sd.style.color = "orangered";
    sd.style.fontSize = "15px";
    sd.style.fontWeight = 600;
    element.appendChild(sd);
}